﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using AutoR.Models;
using AutoR.Services;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Navigation;

namespace AutoR.ViewModels.Home
{
	// Token: 0x020000D0 RID: 208
	public class ShipListViewModel : BindableBase, INavigationAware, INavigatedAware, INavigatingAware
	{
		// Token: 0x17000123 RID: 291
		// (get) Token: 0x0600041F RID: 1055 RVA: 0x0004D422 File Offset: 0x0004B622
		private INavigationService NavigationService { get; }

		// Token: 0x17000124 RID: 292
		// (get) Token: 0x06000420 RID: 1056 RVA: 0x000408F6 File Offset: 0x0003EAF6
		public GameData Game
		{
			get
			{
				return Runtime.Game;
			}
		}

		// Token: 0x17000125 RID: 293
		// (get) Token: 0x06000421 RID: 1057 RVA: 0x0004D42A File Offset: 0x0004B62A
		// (set) Token: 0x06000422 RID: 1058 RVA: 0x0004D434 File Offset: 0x0004B634
		public bool Stat
		{
			[CompilerGenerated]
			get
			{
				return this.<Stat>k__BackingField;
			}
			[CompilerGenerated]
			set
			{
				if (this.<Stat>k__BackingField == value)
				{
					return;
				}
				this.<Stat>k__BackingField = value;
				this.OnPropertyChanged(<>PropertyChangedEventArgs.StatB);
				this.OnPropertyChanged(<>PropertyChangedEventArgs.Stat);
			}
		}

		// Token: 0x17000126 RID: 294
		// (get) Token: 0x06000423 RID: 1059 RVA: 0x0004D46C File Offset: 0x0004B66C
		public bool StatB
		{
			get
			{
				return !this.Stat;
			}
		}

		// Token: 0x17000127 RID: 295
		// (get) Token: 0x06000424 RID: 1060 RVA: 0x0004D477 File Offset: 0x0004B677
		public DelegateCommand<UserShip> ChangeShipCommand { get; }

		// Token: 0x17000128 RID: 296
		// (get) Token: 0x06000425 RID: 1061 RVA: 0x0004D47F File Offset: 0x0004B67F
		// (set) Token: 0x06000426 RID: 1062 RVA: 0x0004D488 File Offset: 0x0004B688
		public List<ShipConfig> List
		{
			[CompilerGenerated]
			get
			{
				return this.<List>k__BackingField;
			}
			[CompilerGenerated]
			set
			{
				if (object.Equals(this.<List>k__BackingField, value))
				{
					return;
				}
				this.<List>k__BackingField = value;
				this.OnPropertyChanged(<>PropertyChangedEventArgs.List);
			}
		}

		// Token: 0x17000129 RID: 297
		// (get) Token: 0x06000427 RID: 1063 RVA: 0x0004D4B8 File Offset: 0x0004B6B8
		// (set) Token: 0x06000428 RID: 1064 RVA: 0x0004D4C0 File Offset: 0x0004B6C0
		public List<UserShip> UserList
		{
			[CompilerGenerated]
			get
			{
				return this.<UserList>k__BackingField;
			}
			[CompilerGenerated]
			set
			{
				if (object.Equals(this.<UserList>k__BackingField, value))
				{
					return;
				}
				this.<UserList>k__BackingField = value;
				this.OnPropertyChanged(<>PropertyChangedEventArgs.UserList);
			}
		}

		// Token: 0x1700012A RID: 298
		// (get) Token: 0x06000429 RID: 1065 RVA: 0x0004D4F0 File Offset: 0x0004B6F0
		// (set) Token: 0x0600042A RID: 1066 RVA: 0x0004D4F8 File Offset: 0x0004B6F8
		public int ShipType
		{
			[CompilerGenerated]
			get
			{
				return this.<ShipType>k__BackingField;
			}
			[CompilerGenerated]
			set
			{
				if (this.<ShipType>k__BackingField == value)
				{
					return;
				}
				this.<ShipType>k__BackingField = value;
				this.OnPropertyChanged(<>PropertyChangedEventArgs.ShipType);
			}
		}

		// Token: 0x0600042B RID: 1067 RVA: 0x0004D528 File Offset: 0x0004B728
		public ShipListViewModel(INavigationService navigationService)
		{
			this.NavigationService = navigationService;
			this.ChangeShipCommand = new DelegateCommand<UserShip>(async delegate(UserShip s)
			{
				await this.NavigationService.NavigateAsync("ShipSetting", new NavigationParameters
				{
					{
						"ship",
						s
					}
				});
			});
			Runtime.Configs.shipCard.ForEach(delegate(ShipConfig i)
			{
				i.isHave = Runtime.Game.UnlockShip.Contains(i.cid);
			});
			this.List = Runtime.Configs.shipCard;
			this.GenList();
		}

		// Token: 0x0600042C RID: 1068 RVA: 0x0004D5A0 File Offset: 0x0004B7A0
		public void GenList()
		{
			List<UserShip> source = this.Game.UserShip.ToList<UserShip>();
			if (this.ShipType != 0)
			{
				int[] id = new int[]
				{
					0,
					1,
					2,
					3,
					4,
					5,
					6,
					7,
					8,
					9,
					10,
					11,
					12,
					13,
					14,
					15,
					16,
					23,
					24
				};
				source = (from i in source
				where i.Type == (ShipType)id[this.ShipType]
				select i).ToList<UserShip>();
			}
			source = (from i in source
			orderby i.level descending, i.Type descending
			select i).ToList<UserShip>();
			this.UserList = source.ToList<UserShip>();
		}

		// Token: 0x0600042D RID: 1069 RVA: 0x0004067F File Offset: 0x0003E87F
		public void OnNavigatedFrom(INavigationParameters parameters)
		{
		}

		// Token: 0x0600042E RID: 1070 RVA: 0x0004067F File Offset: 0x0003E87F
		public void OnNavigatedTo(INavigationParameters parameters)
		{
		}

		// Token: 0x0600042F RID: 1071 RVA: 0x0004067F File Offset: 0x0003E87F
		public void OnNavigatingTo(INavigationParameters parameters)
		{
		}
	}
}
